// 入口函数
window.onload = function () {
    // --------------手机端   (下拉导航) 👇-----------------------
    // 获取按钮
    var btn = document.querySelector('button');
    // 获取手机端导航
    var nav_bare = document.querySelector('.nav-bare');
    var flage = true;
    btn.onclick = function () {
        if (flage) {
            nav_bare.className = 'nav-bare on';
            flage = false;
        } else {
            nav_bare.className = 'nav-bare in';
            flage = true;
        }
    };
    // -------------------------轮播图   👇------------------------
    var hd = document.querySelector('.hd .list');
    var span = document.querySelectorAll('.bd span');
    //  排他封装
    function paita(ele) {
        for (var i = 0; i < ele.length; i++) {
            ele[i].className = '';
        }
    }
    // -----------------轮播图匀速封装  👇--------------------
    function lowe(ele, target) {
        // 调用函数先清除定时器
        clearInterval(ele.timerId);
        ele.timerId = setInterval(function () {
            // 到达目标值清除定时器
            if (ele.offsetLeft == target) {
                clearInterval(ele.timerId)
            } else {
                // 计算步长  匀速动画
                var seed = (target - ele.offsetLeft) / 10;
                seed = seed > 0 ? Math.ceil(seed) : Math.floor(seed);
                ele.style.left = seed + ele.offsetLeft + "px";
            }
        }, 10);
    }
    // 照片移动标志位
    var flag = 0;
    // 小圆点标志位
    var count = 0;
    var timerId1;
    function autoplay() {
        clearInterval(timerId1);
        timerId1 = setInterval(function () {
            flag++;
            count++;
            if (count == span.length) {
                count = 0;
            }
            if (flag == hd.children.length) {
                hd.style.left = 0 + "px";
                flag = 1;
            }
            paita(span);
            span[count].className = 'abc';
            var target = flag * (-hd.children[0].clientWidth);
            lowe(hd, target);
        }, 3000);
    }
    autoplay();
    // 焦点轮播
    for (var k = 0; k < span.length; k++) {
        span[k].index = k;
        span[k].onclick = function () {
            paita(span);
            this.className = 'abc';
            flag = this.index;
            count = this.index;
            var target = this.index * (-hd.children[0].clientWidth);
            lowe(hd, target);
        }
    }

    var banner = document.querySelector('.banner');
    // 鼠标进入暂停
    banner.onmouseenter = function () {
        clearInterval(timerId1);
    }
    // 鼠标移出开始
    banner.onmouseleave = function () {
        autoplay();
    }



    // --------------我们的服务 (放大效果) 👇-----------
    var item = document.querySelectorAll('.section3 .table li');
    for (var j = 0; j < item.length; j++) {
        item[j].onmouseover = function () {
            for (var i = 0; i < item.length; i++) {
                item[i].className = '';
            }
            this.className = 'card-active';
        }
    }

    // 我们的成绩
    var runnumber = document.querySelectorAll('.run-number');
    console.log(runnumber);
    var num2 = 0;
    var num3 = 0;
    var num4 = 0;
    var num5 = 0;
    num2.index = setInterval(function () {
        if (num2 == 398) {
            clearInterval(num2.index)
        } else {
            runnumber[0].innerHTML = '18' + ',' + num2;
            num2++;
        }

    }, 10)
    num3.index = setInterval(function () {
        if (num3 == 101) {
            clearInterval(num3.index)
        } else {
            runnumber[3].innerHTML = num3;
            num3++;
        }

    }, 21)
    num4.index = setInterval(function () {
        if (num4 == 99) {
            clearInterval(num4.index)
        } else {
            runnumber[1].innerHTML = num4 + '.' + '8';
            num4++;
        }

    }, 26);
    num5.index = setInterval(function () {
        if (num5 == 274) {
            clearInterval(num4.index)
        } else {
            runnumber[2].innerHTML = '3' + ',' + num5;
            num5++;
        }

    }, 12);
};
// -----------通用-banner大图自定义缩放-  👇---------------
$(function () {
    var zoomWidth = 992; //小于992px的视口都会对原图进行缩放
    var maxWidth = 1920;    //最大宽度1920px
    var ratio = 1;          //缩放比例
    var viewWidth = window.innerWidth; // 获取视口宽度
    var zoomSlider = function () {
        if (viewWidth < 768) {
            ratio = viewWidth / zoomWidth;
        } else if (viewWidth < zoomWidth) {
            ratio = zoomWidth / (zoomWidth + (zoomWidth - 750));
        } else {
            ratio = 1;
        }
        var width = maxWidth * ratio; //缩放宽度
        $(".hd .list li a img").each(function () {
            $(this).css({
                "width": width,
                "max-width": width,
                "margin-left": -(width - viewWidth) / 2
            });
        });
    };
    zoomSlider();
    //  ----------监听屏幕发生变化时的事件  👇-------------
    $(window).resize(function () {
        viewWidth = window.innerWidth;   //获取新的视口宽度
        zoomSlider();
    });


    // ------绑定点击事件回到顶部 (回到顶部显示隐藏)  👇---------------
    $(window).scroll(function () {
        let p = $(this).scrollTop();
        if (p >= 400) {
            $('.Top').fadeIn(600);
        } else {
            $('.Top').fadeOut(600);
        }
    });
    $('.Top').click(function () {
        $('html').animate({
            scrollTop: 0
        }, 800);
    });
});














//----------------------wavas线条动画  👇----------------
$(function () {
    function a() {
        var a = $(window).width(),
            b = (768 - a) / 768 + 1,
            c = 1;
        fmhPara = $(".feature-mi").height() < 641 || $(".feature-ai").height() < 641 || $(".feature-bi").height() < 641 ? 0 : 1, 768 > a ? ($(".mi-headline-bg").css("height", $(".feature-mi").height() + 28 * b * c + "px"), $(".ai-headline-bg").css("height", $(".feature-ai").height() + 28 * b * c + "px"), $(".bi-headline-bg").css("height", $(".feature-bi").height() + 28 * b * c + "px"), $(".ee-headline-bg").css("height", $(".feature-ee").height() + parseInt($(".feature-ee").css("padding-top")) + 20 * b + "px")) : ($(".mi-headline-bg").removeAttr("style"), $(".ai-headline-bg").removeAttr("style"), $(".bi-headline-bg").removeAttr("style"), $(".ee-headline-bg").removeAttr("style"))
    }
    setTimeout(function () {
        a()
    }, 100), $(window).resize(function () {
        a()
    })
}), function (a, b) {
    "use strict";
    "function" == typeof define && "object" == typeof define.amd ? define([], function () {
        return b(a)
    }) : a.SineWaves = b(a)
}(this, function () {
    "use strict";

    function a(a) {
        if (this.options = i.defaults(this.options, a), this.el = this.options.el, delete this.options.el, !this.el) return false;
        if (this.ctx = this.el.getContext("2d"), this.waves = this.options.waves, delete this.options.waves, !this.waves || !this.waves.length) throw "No waves specified";
        this.dpr = window.devicePixelRatio || 1, this.updateDimensions(), window.addEventListener("resize", this.updateDimensions.bind(this)), this.setupUserFunctions(), this.easeFn = i.getFn(n, this.options.ease, "linear"), this.rotation = i.degreesToRadians(this.options.rotate), i.isType(this.options.running, "boolean") && (this.running = this.options.running), this.setupWaveFns(), this.loop()
    }
    function b(a, b) {
        return i.isType(a, "number") ? a : (a = a.toString(), a.indexOf("%") > -1 ? (a = parseFloat(a), a > 1 && (a /= 100), b * a) : a.indexOf("px") > -1 ? parseInt(a, 10) : void 0)
    }
    Function.prototype.bind || (Function.prototype.bind = function (a) {
        if ("function" != typeof this) throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
        var b = Array.prototype.slice.call(arguments, 1),
            c = this,
            d = function () { },
            e = function () {
                return c.apply(this instanceof d && a ? this : a, b.concat(Array.prototype.slice.call(arguments)))
            };
        return d.prototype = this.prototype, e.prototype = new d, e
    });
    for (var c = ["ms", "moz", "webkit", "o"], d = 0; d < c.length && !window.requestAnimationFrame; ++d) window.requestAnimationFrame = window[c[d] + "RequestAnimationFrame"], window.cancelAnimationFrame = window[c[d] + "CancelAnimationFrame"] || window[c[d] + "CancelRequestAnimationFrame"];
    if (!window.requestAnimationFrame) {
        var e = 0;
        window.requestAnimationFrame = function (a) {
            var b = (new Date).getTime(),
                c = Math.max(0, 16 - (b - e)),
                d = window.setTimeout(function () {
                    a(b + c)
                }, c);
            return e = b + c, d
        }
    }
    window.cancelAnimationFrame || (window.cancelAnimationFrame = function (a) {
        clearTimeout(a)
    });
    var f = Math.PI / 180,
        //原来的值为g=2 * Math.PI 用于修正sineinout右边的正弦值
        g = 2.6 * Math.PI,
        h = Math.PI / 2,
        i = {},
        j = i.isType = function (a, b) {
            var c = {}.toString.call(a).toLowerCase();
            return c === "[object " + b.toLowerCase() + "]"
        },
        k = i.isFunction = function (a) {
            return j(a, "function")
        },
        l = i.isString = function (a) {
            return j(a, "string")
        },
        m = (i.isNumber = function (a) {
            return j(a, "number")
        }, i.shallowClone = function (a) {
            var b = {};
            for (var c in a) a.hasOwnProperty(c) && (b[c] = a[c]);
            return b
        }),
        n = (i.defaults = function (a, b) {
            j(b, "object") || (b = {});
            var c = m(a);
            for (var d in b) b.hasOwnProperty(d) && (c[d] = b[d]);
            return c
        }, i.degreesToRadians = function (a) {
            if (!j(a, "number")) throw new TypeError("Degrees is not a number");
            return a * f
        }, i.getFn = function (a, b, c) {
            return k(b) ? b : l(b) && k(a[b.toLowerCase()]) ? a[b.toLowerCase()] : a[c]
        }, {});
    n.linear = function (a, b) {
        return b
    }, n.sinein = function (a, b) {
        return b * (Math.sin(a * Math.PI - h) + 1) * .5
    }, n.sineout = function (a, b) {
        return b * (Math.sin(a * Math.PI + h) + 1) * .5
    }, n.sineinout = function (a, b) {
        return b * (Math.sin(a * g - h) + 1) * .5
    };
    var o = {};
    o.sine = function (a) {
        return Math.sin(a)
    }, o.sin = o.sine, o.sign = function (a) {
        return a = +a, 0 === a || isNaN(a) ? a : a > 0 ? 1 : -1
    }, o.square = function (a) {
        return o.sign(Math.sin(a * g))
    }, o.sawtooth = function (a) {
        return 2 * (a - Math.floor(a + .5))
    }, o.triangle = function (a) {
        return Math.abs(o.sawtooth(a))
    }, a.prototype.options = {
        speed: 10,
        rotate: 0,
        ease: "Linear",
        wavesWidth: "95%"
    }, a.prototype.setupWaveFns = function () {
        for (var a = -1, b = this.waves.length; ++a < b;) this.waves[a].waveFn = i.getFn(o, this.waves[a].type, "sine")
    }, a.prototype.setupUserFunctions = function () {
        i.isFunction(this.options.resizeEvent) && (this.options.resizeEvent.call(this), window.addEventListener("resize", this.options.resizeEvent.bind(this))), i.isFunction(this.options.initialize) && this.options.initialize.call(this)
    };
    var p = {
        timeModifier: 1,
        amplitude: 50,
        wavelength: 50,
        segmentLength: 10,
        lineWidth: 1,
        strokeStyle: "rgba(255, 255, 255, 0.2)",
        type: "Sine"
    };
    return a.prototype.getDimension = function (a) {
        return i.isNumber(this.options[a]) ? this.options[a] : i.isFunction(this.options[a]) ? this.options[a].call(this, this.el) : "width" === a ? this.el.clientWidth : "height" === a ? this.el.clientHeight : void 0
    }, a.prototype.updateDimensions = function () {
        var a = this.getDimension("width"),
            c = this.getDimension("height");
        this.width = this.el.width = a * this.dpr, this.height = this.el.height = c * this.dpr, this.el.style.width = a + "px", this.el.style.height = c + "px", this.waveWidth = b(this.options.wavesWidth, this.width), this.waveLeft = (this.width - this.waveWidth) / 2, this.yAxis = this.height / 2
    }, a.prototype.clear = function () {
        this.ctx.clearRect(0, 0, this.width, this.height)
    }, a.prototype.time = 0, a.prototype.update = function (a) {
        this.time = this.time - .007, "undefined" == typeof a && (a = this.time);
        var b = -1,
            c = this.waves.length;
        for (this.clear(), this.ctx.save(), this.rotation > 0 && (this.ctx.translate(this.width / 2, this.height / 2), this.ctx.rotate(this.rotation), this.ctx.translate(-this.width / 2, -this.height / 2)); ++b < c;) {
            var d = this.waves[b].timeModifier || 1;
            this.drawWave(a * d, this.waves[b])
        }
        this.ctx.restore(), b = void 0, c = void 0
    }, a.prototype.getPoint = function (a, b, c) {
        var d = a * this.options.speed + (-this.yAxis + b) / c.wavelength,
            e = c.waveFn.call(this, d, o),
            f = this.easeFn.call(this, b / this.waveWidth, c.amplitude);
        return d = b + this.waveLeft, e = f * e + this.yAxis, {
            x: d,
            y: e
        }
    }, a.prototype.drawWave = function (a, b) {
        b = i.defaults(p, b), this.ctx.lineWidth = b.lineWidth * this.dpr, this.ctx.strokeStyle = b.strokeStyle, this.ctx.lineCap = "butt", this.ctx.lineJoin = "round", this.ctx.beginPath(), this.ctx.moveTo(0, this.yAxis), this.ctx.lineTo(this.waveLeft, this.yAxis);
        var c, d;
        for (c = 0; c < this.waveWidth; c += b.segmentLength) d = this.getPoint(a, c, b), this.ctx.lineTo(d.x, d.y), d = void 0;
        c = void 0, b = void 0, this.ctx.lineTo(this.width, this.yAxis), this.ctx.stroke()
    }, a.prototype.running = !0, a.prototype.loop = function () {
        this.running === !0 && this.update(), window.requestAnimationFrame(this.loop.bind(this))
    }, a.prototype.Waves = o, a.prototype.Ease = n, a
}), $(function () {
    var a = new SineWaves({
        el: document.getElementById("waves"),
        //设置正弦波速度 
        speed: 4,
        width: function () {
            var a = $(document).width();
            //原来的值, 设置正弦波的宽度, 现在设置为与元素同宽
            //return 768 > a ? 3 * $("#waves").parent().width() : 1.4 * $("#waves").parent().width()
            return 1.4 * $("#waves").parent().width()
        },
        height: function () {
            return $("#waves").parent().height()
        },
        //原来的值, 可以正弦波宽度, 居中, 两边超出部分隐藏
        //wavesWidth: "100%",
        wavesWidth: "130%",//150
        ease: "SineInOut",
        waves: [{
            timeModifier: .5,
            lineWidth: 2,
            amplitude: 150,
            wavelength: 200,
            segmentLength: 1
        }, {
            timeModifier: .5,
            lineWidth: 2,
            amplitude: 100,
            wavelength: 150,
            segmentLength: 1
        }, {
            timeModifier: .5,
            lineWidth: 2,
            amplitude: 50,
            wavelength: 80,
            segmentLength: 1
        }],
        initialize: function () { },
        resizeEvent: function () {
            var a = this.ctx.createLinearGradient(0, 0, this.width, 0);
            //原来的值, 设置线条渐变透明度, 以及开始激变的位置
            //a.addColorStop(0, "rgba(255, 255, 255, 0)"), a.addColorStop(.5, "rgba(255, 255, 255, 0.2)"), a.addColorStop(1, "rgba(255, 255, 255, 0)");
            a.addColorStop(0, "rgba(255, 255, 255, 0)"), a.addColorStop(.1, "rgba(255, 255, 255, 0.2)"), a.addColorStop(1, "rgba(255, 255, 255, 0)");
            for (var b = -1, c = this.waves.length; ++b < c;) this.waves[b].strokeStyle = a;
            b = void 0, c = void 0, a = void 0
        }
    }),
        b = $("#waves"),
        c = $(document).scrollTop(),
        d = $(document).scrollTop() + $(window).height(),
        e = b.offset().top + b.height(),
        f = b.offset().top;
    (c > e || f > d) && (a.running = !1, a.update()), $(window).bind("scroll", function () {
        c = $(document).scrollTop(), d = $(document).scrollTop() + $(window).height(), e = b.offset().top + b.height(), f = b.offset().top, c > e || f > d ? (a.running = !1, a.update()) : (a.running = !0, a.update())
    })
});
